using System;
using UnityEngine;

namespace ConsentManagementProviderLib.Android
{
	internal static class CmpJavaToUnityUtils
	{
		private const string UnityUtilsPackageName = "com.sourcepoint.cmplibrary.unity3d.UnityUtils";

		internal static AndroidJavaObject ConvertArrayToList(AndroidJavaObject[] array)
		{
			using AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.sourcepoint.cmplibrary.unity3d.UnityUtils");
			CmpDebugUtil.Log("C# : passing Array to List conversion to Android's UnityUtils...");
			object[] args = new AndroidJavaObject[1][] { array };
			return androidJavaClass.CallStatic<AndroidJavaObject>("arrayToList", args);
		}

		internal static Exception ConvertThrowableToError(AndroidJavaObject rawErr)
		{
			using AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.sourcepoint.cmplibrary.unity3d.UnityUtils");
			try
			{
				CmpDebugUtil.Log("C# : passing Throwable to Exception conversion to Android's UnityUtils...");
				androidJavaClass.CallStatic("throwableToException", rawErr);
			}
			catch (AndroidJavaException result)
			{
				return result;
			}
			return new NotImplementedException();
		}
	}
}
